#include <yangutil/buffer/YangVideoBuffer.h>

#include <stdlib.h>


YangVideoBuffer::~YangVideoBuffer(void)
{

}

YangVideoBuffer::YangVideoBuffer(int32_t pBitDepthLen)
{
	reset();
	m_bitDepthLen=pBitDepthLen;
	m_frames=0;
	m_cache_num = 5;
	m_width=0;
	m_height=0;
	m_length=0;
	m_frames=0;
}


YangVideoBuffer::YangVideoBuffer(int32_t pwid,int32_t phei,int32_t ptype,int32_t pBitDepthLen){
	reset();
	m_bitDepthLen=pBitDepthLen;
	m_width=pwid;
	m_height=phei;
	m_length=(ptype==12?m_width*m_height*3/2:m_width*m_height*2)*m_bitDepthLen;//3/2;
	m_cache_num=5;
	initFrames(m_cache_num,m_length);
	m_frames=0;

}
void YangVideoBuffer::init(int32_t pwid,int32_t phei,int32_t ptype){
	reset();
	m_width=pwid;
	m_height=phei;
	m_length=(ptype==12?m_width*m_height*3/2:m_width*m_height*2)*m_bitDepthLen;//3/2;
	m_cache_num=5;
	initFrames(m_cache_num,m_length);

	m_frames=0;

}

void YangVideoBuffer::reset() {
	resetIndex();
}


void YangVideoBuffer::putVideo(YangFrame* pframe){
	putFrame(pframe);
}

void YangVideoBuffer::getVideo(YangFrame* pframe){

	getFrame(pframe);
}
uint8_t * YangVideoBuffer::getVideoRef(YangFrame* pframe){
	return getFrameRef(pframe);

}

int64_t YangVideoBuffer::getTimestamp(int64_t *ptimestamp){

	YangFrame* f=getCurFrameRef();
		if(f) *ptimestamp=f->timestamp;
	return 0;
}

